From dfa894b76ee3584bf169710c78c57330c5d6ee67 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 29 Nov 2023 12:28:03 +0100 Subject: fix(pages,services): make thematics & topics pages usable again When I refactored the fetchers and convertors in #f111685 I forgot to convert WPThematicPreview and WPTopicPreview so the thematics and topics pages was broken. I also: * removed the ToC added by error in #70b4f63 * fix heading styles * fix website url in topics pages --- src/pages/sujet/[slug].tsx | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'src/pages/sujet/[slug].tsx') diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx index c63906f..483df48 100644 --- a/src/pages/sujet/[slug].tsx +++ b/src/pages/sujet/[slug].tsx @@ -14,11 +14,11 @@ import { Page, PageHeader, PageSidebar, - TocWidget, PageBody, } from '../../components'; import { - convertTaxonomyToPageLink, + convertWPTopicPreviewToPageLink, + convertWPTopicToTopic, fetchAllTopicsSlugs, fetchTopic, fetchTopicsCount, @@ -36,7 +36,7 @@ import { getWebPageSchema, } from '../../utils/helpers'; import { loadTranslation, type Messages } from '../../utils/helpers/server'; -import { useBreadcrumb, useHeadingsTree } from '../../utils/hooks'; +import { useBreadcrumb } from '../../utils/hooks'; export type TopicPageProps = { currentTopic: Topic; @@ -54,7 +54,7 @@ const TopicPage: NextPageWithLayout = ({ cover, dates, seo, - thematics, + relatedThematics, website: officialWebsite, } = meta; const intl = useIntl(); @@ -62,7 +62,6 @@ const TopicPage: NextPageWithLayout = ({ title, url: `${ROUTES.TOPICS}/${slug}`, }); - const { ref, tree } = useHeadingsTree({ fromLevel: 2 }); const { asPath } = useRouter(); const webpageSchema = getWebPageSchema({ @@ -103,11 +102,6 @@ const TopicPage: NextPageWithLayout = ({ ); const pageUrl = `${CONFIG.url}${asPath}`; - const tocTitle = intl.formatMessage({ - defaultMessage: 'Table of Contents', - description: 'PageLayout: table of contents title', - id: 'eys2uX', - }); return ( @@ -144,13 +138,7 @@ const TopicPage: NextPageWithLayout = ({ website: officialWebsite, }} /> - - {tocTitle}} - tree={tree} - /> - - + {/*eslint-disable-next-line react/no-danger -- Necessary for content*/} {content ?
: null} {articles ? ( @@ -175,14 +163,14 @@ const TopicPage: NextPageWithLayout = ({ ) : null} - {thematics ? ( + {relatedThematics ? ( {thematicsListTitle} } - items={getLinksItemData(thematics)} + items={getLinksItemData(relatedThematics)} /> ) : null} = async ({ first: totalTopics, }); const allTopics = allTopicsEdges.edges.map((edge) => - convertTaxonomyToPageLink(edge.node) + convertWPTopicPreviewToPageLink(edge.node) ); const topicsLinks = allTopics.filter( (topic) => topic.url !== `${ROUTES.TOPICS}/${(params as TopicParams).slug}` @@ -223,7 +211,9 @@ export const getStaticProps: GetStaticProps = async ({ return { props: { - currentTopic: JSON.parse(JSON.stringify(currentTopic)), + currentTopic: JSON.parse( + JSON.stringify(convertWPTopicToTopic(currentTopic)) + ), topics: JSON.parse(JSON.stringify(topicsLinks)), translation, }, -- cgit v1.2.3